package com.ldzy.dao;

import com.ldzy.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {
    @Select("select * from users where uid=#{uid}")
    @Results({@Result(property = "idCard",column = "idCard",one = @One(select = "com.ldzy.dao.IdcoreDao.findById")),
            @Result(property = "ordersList",column = "uid",many =@Many(select = "com.ldzy.dao.OrdersDao.findOrderByUsersId") )}
    )
    public User findByIdWinidCard(int id);
    @Select("select * from users where uid=#{id}")
    public User findById(int id);
    @Select("select * from users")
    public List<User> all();
    @Insert("insert into users(uname,uage) values(#{uname},#{uage})")
    public void  addname(User user);
//  @Delete("delete from users where uname=#{name}")
//    public  void  dat(User user);
  @Update(" updater users set uname=#{uname},uage=#{uage} where uid=#{uid}")
    public  void edu(User user);
  @Update("<script>update users <trim prefix=\"set\" suffixOverrides=\",\">" +
          "     <if test=\"uname !=null and uname !=''\">uname=#{uname},</if>"+
          "     <if test=\"uage !=null and uage !=''\">uage=#{uage},</if>"+
          "     </trim>"    +
          "     where uid=#{uid}"+
          "</script>")
    public  void ewd(User user);
    @Update("update users set uname=#{name} where uid=#{id}")
    public  void updateDUser(@Param("id") int id ,@Param("name") String name);
}
